<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	User u = new User();
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect("../index.jsp");
	}
	String orby = (String) request.getParameter("sort");
	if (orby != null) {
		if (orby.equals("eu")) {
			orby = "user_name";
		} else if (orby.equals("em")) {
			orby = "email";
		} else if (orby.equals("ul")) {
			orby = "user_level";
		} else if (orby.equals("at")) {
			orby = "active";
		} else {
			orby = "";
		}
	} else {
		orby = "";
	}
	int[] uid = u.getUID(orby);
%>
<title>MYFILM - User Manage</title>
<h2>Manage Categories</h2>
<table>
	<thead>
		<tr>
			<th><a href="user.jsp?sort=un">User Name</a></th>
			<th><a href="user.jsp?sort=em">Email</th>
			<th><a href="user.jsp?sort=ul">User Level</th>
			<th><a href="user.jsp?sort=at">Active</th>
			<th>Edit</th>
			<th>Delete</th>
		</tr>
	</thead>
	<tbody>
		<%
			for (int i : uid) {
				u = u.getUserByID(i);
		%>
		<tr>
			<td><%=u.getUserName()%></td>
			<td><%=u.getEmail()%></td>
			<td><%=u.getUser_level()%></td>
			<td><%=(u.getActive().equals("yes")) ? "Yes" : "No"%></td>
			<td><a class='edit' href='user.jsp?site=e&uid=<%=u.getUid()%>'>Edit</a></td>
			<td><a class='delete' href='delete.jsp?uid=<%=u.getUid()%>'>Delete</a></td>
		</tr>
		<%
			}
		%>
	</tbody>
</table>

